package design_1_factory.demo1.factory;

import design_1_factory.demo1.server.Compute;
import design_1_factory.demo1.server.impl.Add;
import design_1_factory.demo1.server.impl.Subtract;

/**
 * 创建一个工厂，根据不同的参数，获取到对应的实现类
 *
 * @author wangsong
 * @email 1720696548@qq.com
 * @date 2022/1/18 11:35
 */
public class ComputeFactory {

	/**
	 * 使用 getShape 方法获取形状类型的对象
	 *
	 * @author wangsong
	 * @email 1720696548@qq.com
	 * @date 2022/1/18 11:42
	 */
	public Compute compute(String shapeType) {
		if (shapeType.equalsIgnoreCase("Add")) {
			return new Add();
		} else if (shapeType.equalsIgnoreCase("Subtract")) {
			return new Subtract();
		}
		return null;
	}
}